<?php
/**
 * Vbot 微信机器人控制器
 * @App	
 * @Group 
 * @Action VbotAction
 * @author lilei
 * @date 2018年11月15日
 *
 */
namespace app\crontab\controller;
use app\common\service\PidFile;
use app\common\service\SentryClientService;
use app\common\service\VbotService;

class Vbot extends CrontabCommon {
	/**
	 * 启动机器人
	 */
	public function run() {
		$user_mark = $_GET['user'];
		$app = "VbotRunUser_{$user_mark}";
		if (!PidFile::createPidFile($app, 1)) {
			echo '进程已启动足够数量' . PHP_EOL;
			return;
		}
		$sentry = new SentryClientService();
		$robot = new VbotService();
		try {
			$robot->run();
		} catch ( \Exception $e) {
			echo PHP_EOL;
			echo $e->getMessage();
			echo PHP_EOL;
			$sentry->sendMessage($e->getMessage(), SentryClientService::ERROR);
		}
		
	}
}